package org.shel

import org.atmosphere.cpr.AtmosphereResourceEvent;
import org.atmosphere.cpr.AtmosphereResourceEventListener;
import grizzled.slf4j.Logger
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * An event logger so we can see the various events being processed
 * by the atmosphere system.
 */
class EventsLogger extends AtmosphereResourceEventListener {

    val logger = Logger[this.Type]

    def onSuspend(event : AtmosphereResourceEvent[HttpServletRequest, HttpServletResponse])
        logger.info("onSuspend(): {}", event)

    def onResume(event : AtmosphereResourceEvent[HttpServletRequest, HttpServletResponse])
        logger.info("onResume(): {}", event)

    def onDisconnect(event : AtmosphereResourceEvent[HttpServletRequest, HttpServletResponse])
        logger.info("onDisconnect(): {}", event)

    def onBroadcast(event : AtmosphereResourceEvent[HttpServletRequest, HttpServletResponse])
        logger.info("onBroadcast(): {}", event)

    def onThrowable(event : AtmosphereResourceEvent[HttpServletRequest, HttpServletResponse])
        logger.warn("onThrowable(): {}", event)
}
